package client.gui;

import java.awt.Font;
import java.awt.Color;

import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;

import client.Office;

public class OfficeInfoPanel extends ItemPanel {
    private static final long serialVersionUID = -8635439676859968674L;
	JLabel officeName;
	JLabel officeLocation;
	JLabel officePhone;
	JLabel officeEmail;
	int officeRef;
	
	final JLabel locLabel = new JLabel("Location: ");
	final JLabel phoneLabel = new JLabel("Phone: ");
	final JLabel emailLabel = new JLabel("Email: ");
	final JLabel servicesLabel = new JLabel("SERVICES >>");
	
	public OfficeInfoPanel(Office o){
		officeName = new JLabel(o.getName());
		officeLocation = new JLabel(o.getLocation());
		officePhone = new JLabel(o.getPhone());
		officeEmail = new JLabel(o.getEmail());
		officeRef = o.getRef();
		
		init();
	}
	
	private void init() {

		Font f = null;
		f = officeName.getFont();
		officeName.setFont(new Font(f.getName(), Font.BOLD, f.getSize() + 7));

		f = servicesLabel.getFont();
		servicesLabel.setFont(new Font(f.getName(), Font.BOLD, f.getSize() - 4));
		servicesLabel.setForeground(Color.BLUE);

		GroupLayout layout = new GroupLayout(this);
		layout.setAutoCreateContainerGaps(true);
		layout.setAutoCreateGaps(true);
		setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup()
				.addComponent(officeName)
				.addGroup(layout.createSequentialGroup()
						.addGap(LayoutStyle.getInstance().getPreferredGap(officeName, locLabel, LayoutStyle.ComponentPlacement.INDENT, SwingConstants.EAST, this))
						.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
								.addComponent(locLabel)
								.addComponent(phoneLabel)
								.addComponent(emailLabel))
						.addGroup(layout.createParallelGroup()
								.addComponent(officeLocation)
								.addComponent(officePhone)
								.addComponent(officeEmail)
								.addGroup(layout.createSequentialGroup()										
										.addGap(100)
										.addComponent(servicesLabel)))));
						
		layout.setVerticalGroup(layout.createSequentialGroup()
				.addComponent(officeName)
				.addGroup(layout.createParallelGroup()
						.addGroup(layout.createSequentialGroup()
								.addComponent(locLabel)
								.addComponent(phoneLabel)
								.addComponent(emailLabel))
						.addGroup(layout.createSequentialGroup()
								.addComponent(officeLocation)
								.addComponent(officePhone)
								.addComponent(officeEmail)
								.addComponent(servicesLabel))));
								
   }

	public int getRef(){
		return officeRef;
	}

}
